#ifndef OHOS_VIDEO_FRAME_DRAWER_H_
#define OHOS_VIDEO_FRAME_DRAWER_H_

#include <memory>
#include <GLES3/gl3.h>
#include "api/video/video_frame.h"
#include "common_video/util/matrix.h"
#include "common_video/ohos/ohos_gl_drawer.h"

namespace webrtc {
class VideoFrameDrawer {
 public:
  explicit VideoFrameDrawer();
  virtual ~VideoFrameDrawer();

  void DrawFrame(const std::shared_ptr<OhosGLDrawer> drawer, const webrtc::VideoFrame& frame, const std::shared_ptr<Matrix> additional_render_matrix,
                 int viewport_x, int viewport_y, int viewport_width, int viewport_height);
  void DumpFrame(const webrtc::VideoFrame& frame) const;
 private:
  // Equivalent to the YuvUploader private class
  class YuvUploader {
   public:
    YuvUploader();

    void UploadYuvData(const webrtc::VideoFrame& frame) const;
    void Release() const;

    GLuint* yuv_textures_;
  };

  void CalculateDrawProperties(int frame_width, int frame_height, int frame_rotation, bool is_texture, const std::shared_ptr<Matrix> additional_render_matrix);
  static int Distance(float x0, float y0, float x1, float y1);

  float src_points_[6] = {0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f};
  float dst_points_[6] = {0};
  GLfloat gl_matrix[16] = {0};
  int render_width_ = 0;
  int render_height_ = 0;

  std::shared_ptr<YuvUploader> yuv_uploader_ = nullptr;
  const std::shared_ptr<Matrix> render_matrix_ = std::make_shared<Matrix>();
};
}

#endif // OHOS_VIDEO_FRAME_DRAWER_H_